package com.yuliang.utils.DistributedLock;

import java.util.concurrent.TimeUnit;

/**
 * 分布式锁
 * @author Huangkai
 */
public interface Lock {

    /**
     * 是否加锁
     * @param resourceName
     * @return
     */
    boolean isLock(String resourceName);

    /**
     * 尝试加锁
     * @param waitTime 等待时间，
     * @param leaseTime 锁定时间
     * @param unit
     * @return
     * @throws InterruptedException
     */
    boolean tryLock(long waitTime, long leaseTime, TimeUnit unit);

    /**
     * 加锁
     * @param leaseTime
     * @param unit
     */
    void lock(long leaseTime, TimeUnit unit);

    /**
     * 释放锁
     */
    void unlock();
}
